package pcb.views.sharedAssets 
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.events.MouseEvent;
	import pcb.views.uievents.UIEvent;
	import com.intel.utils.TextRender;
	
	import flash.text.TextFormat;
	
	/**
	 * ...
	 * @author Fintan Boyle
	 */
	public class DialogsMain extends MovieClip 
	{
		private var eulaScreen:EulaMc;
		private var messageScreen:MessageMc;
		private var activityCard:ActivityCardMc;
		private var textFormat:TextFormat;
		
		public function DialogsMain() 
		{
			activityCard = new ActivityCardMc();			
		}
		
		public function displayActivityCard(text:String):void 
		
		{
			activityCard.cardTxt.htmlText = text;
			activityCard.visible = true;
			activityCard.cardTxt.verticalScrollPosition = 1;
			//activityCard.txtNote.text = activityNote;
			
			
			addChild(activityCard);
		}
		
		public function hideActivityCard():void 
		{
			activityCard.visible = false;
		}
		
		public function displayEulaDialog(title:String, text:String, agreeTxt:String, disagreeTxt:String):void 
		{
			eulaScreen = new EulaMc();
			eulaScreen.eulaTxt.setStyle("upSkin",Sprite);
			eulaScreen.eulaTxt.setStyle("focusRectSkin",Sprite);
			
			
			TextRender.createLabel(eulaScreen.eulaTitle, title);
			
			
			if(eulaScreen.myTextLayout != null) {
				eulaScreen.myTextLayout.xmlText = text;
			} else {
				eulaScreen.eulaTxt.htmlText = text;
			}
			
			TextRender.createLabel(eulaScreen.but_disagree.txt, disagreeTxt);
			TextRender.createLabel(eulaScreen.but_agree.txt, agreeTxt);
			
			eulaScreen.but_disagree.addEventListener(MouseEvent.CLICK, onDisagree);
			eulaScreen.but_agree.addEventListener(MouseEvent.CLICK, onAgree);
			
			
			addChild(eulaScreen);
		}
		
		private function onAgree(e:MouseEvent):void 
		{
			var ev:UIEvent = new UIEvent(UIEvent.CLICKED);
			ev.id = "eula-agreed-to-terms";
			this.dispatchEvent(ev);
			
			e.target.removeEventListener(MouseEvent.CLICK, onDisagree);
			e.target.removeEventListener(MouseEvent.CLICK, onAgree);
		}
		
		private function onDisagree(e:MouseEvent):void 
		{
			var ev2:UIEvent = new UIEvent(UIEvent.CLICKED);
			ev2.id = "eula-disagreed-to-terms";
			this.dispatchEvent(ev2);
			
			e.target.removeEventListener(MouseEvent.CLICK, onDisagree);
			e.target.removeEventListener(MouseEvent.CLICK, onAgree);
		}
		
		public function displayMessage(message:String):void 
		{
			messageScreen = new MessageMc();
			
			TextRender.createLabel(messageScreen.messageTxt, message);
			
			addChild(messageScreen);
		}
		
	}
	
}